# # 读文件
# def read_text(fname):
#     with open(fname, 'r', encoding='utf-8') as f:
#         s = f.read()
#     return s


def cut_sentences(content):
    # 结束符号，包含中文和英文的
    end_flag = ['?', '!', '.', '？', '！', '。', '…']
    content_len = len(content)
    sentences = {}
    temp = ''
    i = 0
    for idx, char in enumerate(content):
        # 拼接字符
        temp += char
        # 判断是否已经到了最后一位
        if (idx + 1) == content_len:
            sentences[i] = temp.lstrip()
            temp = ''
            break
        # 判断此字符是否为结束符号
        if char in end_flag:
            # 再判断下一个字符是否为结束符号，如果不是结束符号，则切分句子
            next1_dx = idx + 1
            if not content[next1_dx] in end_flag:
                if content[next1_dx] == ".":
                    continue
                sentences[i] = temp.lstrip()
                temp = ''
                i += 1
    return sentences
#
# print(cut_sentences(read_text("../../data/Mdata/test.txt")))
